<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 200px;
      height: 100px;
      background-color: red;
    }
  </style>
</head>

<body>
  <div class="box">点我呀</div>
  <input type="text" placeholder="请输入呀">
  <script>
    // 1. 获取DOM对象
    const divDom = document.querySelector('.box')
    // 2. 给DOM对象注册事件
    divDom.addEventListener('click', () => {
      divDom.style.backgroundColor = 'green'
      divDom.style.width = '300px'
      divDom.style.height = '200px'
    })
    divDom.addEventListener('mouseenter', () => {
      console.log('进入div标签')
      divDom.style.backgroundColor = 'pink'
      divDom.style.width = '300px'
      divDom.style.height = '200px'
    })
    divDom.addEventListener('mouseleave', () => {
      console.log('离开div标签')
      divDom.style.backgroundColor = 'red'
      divDom.style.width = '200px'
      divDom.style.height = '100px'
    })
  </script>
</body>

</html>